//
//  LSZUploadPicturesTableViewCell.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/20.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZUploadPicturesTableViewCell.h"

@implementation LSZUploadPicturesTableViewCell

-(id)initWithPhoneArray:(NSInteger)number :(NSArray *)mutArrayImageView
{
    self = [super init];
    if (self) {
        for (int i = 0; i<number+1; i++) {
//            NSLog(@"%d>>>>%d",i/3,i%3);
            if(i < 9){
                self.imageViewPicture = [[UIImageView alloc]init];
               self.imageViewPicture.userInteractionEnabled = YES;
                self.imageViewPicture.tag = i + 1;
                self.imageViewPicture.frame = CGRectMake(10+i%3*((ScreenWidth-40)/3+10), 10+i/3*((ScreenWidth-40)/3+10), (ScreenWidth-40)/3, (ScreenWidth-40)/3);
                [self addSubview:self.imageViewPicture];

                if (i < number) {
                    self.imageViewPicture.image = mutArrayImageView[i];
                    self.butDelete = [[UIImageView alloc]init];
                    self.butDelete.tag = i+1;
                    self.butDelete.frame = CGRectMake(self.imageViewPicture.frame.size.width-30, 0, 30, 30);
                    self.butDelete.tag = i+1;
                    self.butDelete.image = [UIImage imageNamed:@"小删除"];
                    [self.butDelete tapGesture:^(UIGestureRecognizer *ges) {
                        int number = i;
                        NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:@(number),@"number", nil];
                        NSNotification *notification =[NSNotification notificationWithName:@"ClickUploadPictures" object:nil userInfo:dic];
                        [[NSNotificationCenter defaultCenter] postNotification:notification];
                        [[NSNotificationCenter defaultCenter] removeObserver:self name:@"ClickUploadPictures" object:nil];
                    }];
                    [self.imageViewPicture addSubview:self.butDelete];
                }else{
                    self.imageViewPicture.image = [UIImage imageNamed:@"添加照片"];
                }
            }
        }
    }
    return self;
}
@end
